/*
 * @Author: yuanshengchao
 * @Date:   2019-09-19 17:51:47
 * @Last Modified by:   yuanshengchao
 * @Last Modified time: 2019-09-19 17:45:19
 */
import moment from 'moment';
import Vue from 'vue';

Vue.filter('age', function(birthday) {
  if (!birthday) return 0;
  return new Date().getYear() - new Date(birthday).getYear();
});
Vue.filter('gender', (val) => {
  if (['M', 'F'].indexOf(val) < 0) return '性别保密';
  return val === 'M' ? '男' : '女';
});
Vue.filter('number', (val, pos) => {
  return parseFloat(val).toFixed(pos);
});
Vue.filter('percent', (val, pos) => {
  if (pos === undefined) return '0%';
  return (parseFloat(val) * 100).toFixed(pos) + '%';
});
